package org.soaism.journey.service.rest;

import java.util.Date;

import org.soaism.journey.service.entities.Journey;
import org.soaism.journey.service.entities.Location;
import org.soaism.journey.service.messages.ChangeLogResponse;
import org.soaism.journey.service.messages.DeleteLogResponse;
import org.soaism.journey.service.messages.GetLogResponse;
import org.soaism.journey.service.messages.NewLogResponse;


public class JourneyServiceImpl implements IJourneyService {
	
	
	public GetLogResponse getLog(int id) {
		Journey j = createDefaultJourney();
		GetLogResponse g = new GetLogResponse();
		g.setJourney(j);
		return g;
	}

	public ChangeLogResponse putLog(int id, Journey body) {
		Journey j = createDefaultJourney();
		j.setComment("changed");
		ChangeLogResponse c = new ChangeLogResponse();
		c.setSuccess(true);
		return c;
	}

	public DeleteLogResponse deleteLog(int id) {
		DeleteLogResponse d = new DeleteLogResponse();
		d.setSuccess(true);
		return d;
	}

	public NewLogResponse postLog(Journey body) {
		
		NewLogResponse res = new NewLogResponse();
		res.setCreationDate("" + new Date());
		res.setJourney(body);
		return res;
	}

	public static Journey createDefaultJourney() {
		Location location = new Location();
		location.setName("home");
		location.setCity("My City");
		Journey j = new Journey();
		j.setComment("JOURNEY 1");
		j.setStartLocation(location);
		return j;
	}
}
